
package guoan.domain;

import guoan.core.jodaJson.DateTimeYYYYMMDDHHMMSSSerializer;
import guoan.core.jodaJson.DateTimeYYYYMMDDSerializer;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 预约考试
 * 
 */
@Entity
public class Exam implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * ID 自动增长
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 内容
     */
    private String content;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateTimeYYYYMMDDHHMMSSSerializer.class)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(name = "create_time")
    private DateTime createTime;

    /**
     * 考试时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = DateTimeYYYYMMDDSerializer.class)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(name = "exam_time")
    private DateTime examTime;

    /**
     * 考试开放时间 （5~20）s ,
     */
    @Column(name = "open_hours")
    private String openHours;

    /**
     * 开始报名时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateTimeYYYYMMDDHHMMSSSerializer.class)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(name = "res_time")
    private DateTime resTime;
    /**
     * 考试标题
     */
    private String title;

    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateTimeYYYYMMDDHHMMSSSerializer.class)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @Column(name = "update_time")
    private DateTime updateTime;

    @Column(name = "join_no")
    private Long joinNo;

    public Exam(){
    }

    public Long getId(){
        return this.id;
    }

    public void setId(Long id){
        this.id = id;
    }

    public String getContent(){
        return this.content;
    }

    public void setContent(String content){
        this.content = content;
    }

    public DateTime getCreateTime(){
        return this.createTime;
    }

    public void setCreateTime(DateTime createTime){
        this.createTime = createTime;
    }

    public DateTime getExamTime(){
        return this.examTime;
    }

    public void setExamTime(DateTime examTime){
        this.examTime = examTime;
    }

    public String getOpenHours(){
        return this.openHours;
    }

    public void setOpenHours(String openHours){
        this.openHours = openHours;
    }

    public String getTitle(){
        return this.title;
    }

    public void setTitle(String title){
        this.title = title;
    }

    public DateTime getUpdateTime(){
        return this.updateTime;
    }

    public void setUpdateTime(DateTime updateTime){
        this.updateTime = updateTime;
    }

    public DateTime getResTime(){
        return resTime;
    }

    public void setResTime(DateTime resTime){
        this.resTime = resTime;
    }

    public Long getJoinNo(){
        return joinNo == null ? 40L : joinNo;
    }

    public void setJoinNo(Long joinNo){
        this.joinNo = joinNo;
    }

    @Override
    public String toString(){
        return "Exam [id=" + id + ", content=" + content + ", createTime="
                + createTime + ", examTime=" + examTime + ", openHours="
                + openHours + ", title=" + title + ", updateTime=" + updateTime
                + "]";
    }

}